#include "stdafx.h"
#include "CObitalCircle.h"


CObitalCircle::CObitalCircle(void)
{
}

CObitalCircle::CObitalCircle(CPoint pBegin, CPoint pEnd, COLORREF cPen)
{
	this->m_pBegin	= pBegin;
	this->m_pEnd	= pEnd;
	m_nAngle = NUM_OF_ANGLE;
	m_pCoordinates = new CPoint[NUM_OF_ANGLE];
	this->m_cPenColor = cPen;
	m_brushColor.CreateSolidBrush(RGB(255, 255, 255));
	m_nPenStyle = PS_SOLID;
	m_nPenWidth = 1;
}

CObitalCircle::CObitalCircle (CPoint m_pBegin, CPoint m_pEnd, COLORREF m_clrBack, COLORREF m_cPenColor, BASESHAPE__T m_nShapeType, INT m_nRotate)
{
	this->m_nRotate = m_nRotate;
	this->m_pBegin = m_pBegin;
	this->m_pEnd = m_pEnd;
	this->m_clrBack = m_clrBack;
	this->m_cPenColor = m_cPenColor;
	this->m_nShapeType = m_nShapeType;
//	this->m_szText = m_szText;
//	this->m_color = m_color;
	m_brushColor.CreateSolidBrush(RGB(255,255,255));
	m_nAngle = NUM_OF_ANGLE;
	m_pCoordinates = new CPoint[NUM_OF_ANGLE];
	m_nPenStyle = PS_SOLID;
	m_nPenWidth = 1;
}

void CObitalCircle::Serialize (CArchive &ar)
{
	if (ar.IsStoring() )
	{
		ar << m_pBegin << m_pEnd << m_clrBack << m_cPenColor << m_nShapeType << m_szText << m_color << m_nRotate;
	}
	else
	{
		int nShapeType;
		ar >> m_pBegin >> m_pEnd >> m_clrBack >> m_cPenColor >> nShapeType >> m_szText >> m_color >> m_nRotate;
		m_nShapeType = (BASESHAPE__T)nShapeType;
	}
}


BOOL CObitalCircle::Draw(CDC *cDC)
{
	CPen cPen(m_nPenStyle, m_nPenWidth, m_cPenColor);
	cDC->SelectObject(&m_brushColor);
	CPen *pOldPen = cDC->SelectObject(&cPen);
	this->setCoordinate();
	cDC->Ellipse(m_rectEclipse);
	cDC->SelectObject(pOldPen);
	pOldPen->DeleteObject();
	return	FALSE;
}

void CObitalCircle::setCoordinate()
{
	CPoint m_pT(15, 15);
	CRect m_rectT(m_pBegin, m_pEnd);
	this->m_pEnd = this->m_pBegin + m_pT;
	m_rectEclipse.TopLeft() = this->m_pBegin - m_pT;
	m_rectEclipse.BottomRight() = this->m_pEnd;

	m_pCoordinates[0] = m_pMax = m_rectEclipse.TopLeft();
	m_pCoordinates[1].x = m_rectEclipse.right;
	m_pCoordinates[1].y = m_rectEclipse.top;
	m_pCoordinates[2] = m_pMin = m_rectEclipse.BottomRight();
	m_pCoordinates[3].x = m_rectEclipse.left;
	m_pCoordinates[3].y = m_rectEclipse.bottom;
}
CObitalCircle::~CObitalCircle(void)
{
}
